package view;

import controller.*;
import java.awt.*;
import javax.swing.*;

public class App extends JApplet{

    private Container contenedor,arriba;
    private List ninosSinRegalo,ninosConRegalo;
    private JPanel listas,botones;
    private JButton[] gift;
    private JLabel conRegalo,sinRegalo,saldo,titulo;
    private String[] ima={"uno","dos","tres","cuatro","cinco","seis","siete"};

    public void init(){
        contenedor = getContentPane();
        contenedor.setLayout(new BorderLayout(5,5));
        arriba = new Container();
        arriba.setLayout(new FlowLayout());

        listas = new JPanel();
        listas.setLayout(new GridBagLayout());
        GridBagConstraints limites = new GridBagConstraints();
        botones = new JPanel();
        botones.setLayout(new GridLayout(2,4,15,13));

        saldo = new JLabel("Saldo Actual: ");
        conRegalo = new JLabel("Niños con regalo");
        sinRegalo = new JLabel("Niños sin regalo");
        titulo = new JLabel("Ayudando a Papá Noel");
        Font auxFont=titulo.getFont();
        titulo.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30));
        arriba.add(titulo);

        ninosSinRegalo = new List(15);
        ninosConRegalo = new List(15);
        gift = new JButton[7];

        for (int i=0; i<30 ; i++){
            ninosSinRegalo.add("Niño "+(i+1));
        }

        for (int i=0; i<7 ; i++){
                gift[i] = new JButton(new ImageIcon("imagenes/"+ima[i]+".jpg"));
                System.out.println("imagenes/"+ima[i]+".jpg");
                botones.add(gift[i]);
        }
        limites.gridx = 0;
        limites.gridy = 0;
        limites.gridheight = 1;
        limites.gridwidth = 1;
        limites.anchor = GridBagConstraints.NORTH;
        listas.add(conRegalo,limites);
        limites.gridx = 1;
        limites.gridy = 0;
        limites.gridheight = 1;
        limites.gridwidth = 1;
        listas.add(sinRegalo,limites);
        limites.gridx = 0;
        limites.gridy = 1;
        limites.gridheight = 15;
        limites.gridwidth = 1;
        limites.weighty = 1.0;
        listas.add(ninosConRegalo,limites);
        limites.gridx = 1;
        limites.gridy = 1;
        limites.gridheight = 15;
        limites.gridwidth = 1;
        listas.add(ninosSinRegalo,limites);

        contenedor.add(listas,BorderLayout.EAST);
        contenedor.add(botones,BorderLayout.CENTER);
        contenedor.add(saldo,BorderLayout.SOUTH);
        contenedor.add(arriba,BorderLayout.NORTH);
        setSize(705,290);
        setContentPane(contenedor);
    }

}
